{%- macro page_url(path) -%}
{%- set page = get_page(path=path) -%}
{{ page.permalink | safe }}
{%- endmacro input -%}

{%- macro current_page_nav(toc) -%}
{% if toc %}
  <details open>
    <summary>In This Page</summary>

    <nav role="navigation">
      <ul>
        {% for h1 in toc %}
        <li>
          <a href="{{'#' ~ h1.id | safe}}">{{ h1.title }}</a>
          {% if h1.children %}
          <ul>
            {% for h2 in h1.children %}
            <li>
              <a href="{{'#' ~ h2.id | safe}}">{{ h2.title }}</a>
            </li>
            {% endfor %}
          </ul>
          {% endif %}
        </li>
        {% endfor %}
      </ul>
    </nav>
  </details>

  <hr />
{% endif %}
{%- endmacro current_page_nav %}

{%- macro nav_prev_item(rel_top, title, path) -%}
<a class="prev" href="{{ rel_top ~ path }}">« {{title}}</a>
{%- endmacro nav_prev_item -%}

{%- macro nav_next_item(rel_top, title, path) -%}
<a class="next" href="{{ rel_top ~ path }}">{{title}} »</a>
{%- endmacro nav_next_item -%}
